package com.example.back.controller;

import com.example.back.dto.req.DeleteCheckupReserveDto;
import com.example.back.dto.req.ProcessCheckupOrderDto;
import com.example.back.dto.resp.CheckupReserveList;
import com.example.back.service.CheckupReserveService;
import com.example.common.entity.CheckupReserve;
import com.example.common.support.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName CheckupReserveController
 * @Author wengjt
 * @Date 2021/5/8 13:43
 * @Description
 **/
@RestController
@RequestMapping("/checkupReserve")
@Api(tags = "体检订单管理")
public class CheckupReserveController {
    @Resource
    private CheckupReserveService checkupReserveService;

    @GetMapping("/list")
    @ApiOperation(value = "获取体检订单列表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "cpName", value = "体检套餐名"),
            @ApiImplicitParam(name = "ctId", value = "体检套餐类型id"),
            @ApiImplicitParam(name = "rStatus", value = "状态数组"),
            @ApiImplicitParam(name = "pageNum", value = "页码"),
            @ApiImplicitParam(name = "pageSize", value = "页大小")
    }
    )
    public Result<CheckupReserveList> getCheckupReserveList(String cpName,
                                                            Long ctId,
                                                            int[] rStatus,
                                                            Integer pageNum,
                                                            Integer pageSize) {
        return Result.success(checkupReserveService.getCheckupReserveList(cpName, ctId, rStatus, pageNum, pageSize));
    }

    @GetMapping("")
    @ApiOperation(value = "获取体检订单详情")
    @ApiImplicitParam(name = "crOrderNo", value = "体检订单id")
    public Result<CheckupReserve> getInfo(String crOrderNo) {
        return Result.success(checkupReserveService.getInfo(crOrderNo));
    }

    @DeleteMapping("")
    @ApiOperation(value = "删除体检订单")
    public Result<Object> deleteCheckupReserve(@RequestBody DeleteCheckupReserveDto dto) {
        return Result.success(checkupReserveService.deleteCheckupReserve(dto.getCrOrderNo()));
    }

    @PostMapping("/process")
    @ApiOperation(value = "处理订单")
    public Result<Object> process(@RequestBody ProcessCheckupOrderDto dto) {
        return Result.success(checkupReserveService.process(dto.getCrOrderNo(), dto.getRStatus(), dto.getCheckup(), dto.getCheckupAddress(), dto.getRemark(), dto.getRefuseReason()));
    }
}
